<?php
/**
 * Created by 荣耀电竞.
 * User: 林子彦 <278805354@qq.com>
 * Date: 2018/6/29 0029
 * Time: 9:59
 */
namespace App\FreeBird\Controllers\Home;
use App\Base\Controllers\Controller;
use App\FreeBird\Contracts\StoreInterface;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\Validator;


class StoreController extends Controller
{

    /**
     * 获取商店接口
     * @return StoreInterface
     */
    public function getStoreInterface(){
        return app()->make(StoreInterface::class);
    }
    /**
     * 发布商店
     */
    public function add(Request $request){

       return $this->getStoreInterface()->setStoreInfo($request->except("token"));
    }


    /**
     * 获取列表
     * @param Request $request
     */
    public function index(Request $request){
        $validator = Validator::make($request->all(), [
            'lng' => 'required',
            'lat' => 'required',
        ]);
        if ($validator->fails()) {
            //$error=$validator->errors()->getMessages();
            $this->throwValidatorException($validator);
        }
        $where=function($query){
        };
        return $this->getStoreInterface()->getListJili($where,$request->except("token"));
    }
    public function detail(Request $request){
        $validator = Validator::make($request->all(), [
            'id' => 'required',
        ]);
        if ($validator->fails()) {
            //$error=$validator->errors()->getMessages();
            $this->throwValidatorException($validator);
        }
        $id=$request->input("id");
        return $this->getStoreInterface()->getInfo(["id"=>$id]);
    }
}